package com.joymart.compute.repository;

import com.joymart.common.data.jdbc.BaseRepository;
import com.joymart.compute.model.VitalityPoint;
import org.springframework.data.jdbc.repository.query.Modifying;
import org.springframework.data.jdbc.repository.query.Query;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;

@Repository
public interface VitalityPointRepository extends BaseRepository<VitalityPoint, String> {



    @Query( "select sum(amount) from vitality_point where owner_id = :userId and valid is true")
    BigDecimal sumUserValidVitalityPoints(String userId);

    @Modifying
    @Query(" update vitality_point set valid = false where contributor_id = :contributorId")
    void invalidateVitalityPointByContributorId(String contributorId);
}
